﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DevToolBox.Cloud.Common
{
    /// <summary>
    /// Method to abstract the interaction with a Microsoft
    /// Entity Framework-like persistance provider
    /// </summary>
    public interface IEFClient
    {
        /// <summary>
        /// Method to query a single or set of T objects based 
        /// on the main/primary key
        /// </summary>
        /// <typeparam name="T">Data type to get</typeparam>
        /// <param name="key">Key for filtering the results</param>
        /// <returns>IEnumerable set of T objects</returns>
        IEnumerable<T> Query<T>(object key);

        /// <summary>
        /// Method to query a single or set of T objects based 
        /// on the main/primary plus a set of conditions
        /// </summary>
        /// <typeparam name="T">Data type to get</typeparam>
        /// <param name="key">Key for filtering the results</param>
        /// <param name="conditionOperator">Condition operators</param>
        /// <param name="values">Set of condition values</param>
        /// <returns>IEnumerable set of T objects</returns>
        IEnumerable<T> Query<T>(object key, string conditionOperator, object[] values);
        
        /// <summary>
        /// Method to fully scan a data repository based on 
        /// a set of conditions
        /// </summary>
        /// <typeparam name="T">Data type to get</typeparam>
        /// <param name="conditions">Condition objects of CommonCondition type</param>
        /// <returns>IEnumerable set of T objects</returns>
        IEnumerable<T> Scan<T>(CommonCondition[] conditions);

        /// <summary>
        /// Frees the unmanaged resources
        /// </summary>
        void Dispose();

        /// <summary>
        /// Method to save a generic set of items.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entities"></param>
        void Save<T>(List<T> entities);

        /// <summary>
        /// Method to delete a generic set of entities
        /// </summary>
        /// <typeparam name="T">Specific data type</typeparam>
        /// <param name="entities">List of Entities to delete</param>
        void Delete<T>(List<T> entities);
    }
}
